from aiogram import F
from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.kbd import Button, Start

from poker_bot.tg_bot.dialogs.getters.users import user_info_getter, user_role_getter
from poker_bot.tg_bot.dialogs.widgets import LocaleText
from poker_bot.tg_bot.states import (
    AdminSG,
    ClientSG,
    CreateWithdrawSG,
    DiscountsSG,
    ReviewsSG,
    UserAccountsSG,
    UserDepositsSG,
)

from .handlers import answer_first_question, contact_support, start_deposit_dialog

start_window = Window(
    LocaleText("welcome-msg", account_id="{account_id}"),
    Button(
        LocaleText("add-funds-btn"),
        id="add_funds",
        on_click=start_deposit_dialog,
    ),
    Start(
        LocaleText("withdraw-funds-btn"),
        id="withdraw_funds",
        state=CreateWithdrawSG.select_payment_method,
    ),
    Start(
        LocaleText("discounts-btn"),
        id="discounts",
        state=DiscountsSG.discounts_list,
    ),
    Start(
        LocaleText("reviews-btn"),
        id="reviews",
        state=ReviewsSG.reviews_list,
    ),
    Start(
        LocaleText("my-accounts-btn"),
        id="my_accounts",
        state=UserAccountsSG.accounts_list,
    ),
    Start(
        LocaleText("my-deposits-btn"),
        id="my_deposits",
        state=UserDepositsSG.deposits_list,
    ),
    Button(
        LocaleText("contact-support-btn"),
        id="contact_support",
        on_click=contact_support,
    ),
    Start(
        LocaleText("admin-btn"),
        id="admin_panel",
        when=F["user_is_admin"],
        state=AdminSG.admin,
    ),
    state=ClientSG.start,
    getter=(user_info_getter, user_role_getter),
)

start_question_window = Window(
    LocaleText("start-question-msg"),
    Button(
        LocaleText("instruction-btn"),
        id="instruction_btn",
        on_click=answer_first_question,
    ),
    Button(LocaleText("club-id-btn"), id="club_id_btn", on_click=answer_first_question),
    Button(
        LocaleText("already-member-btn"),
        id="already_member_btn",
        on_click=answer_first_question,
    ),
    Button(
        LocaleText("plus-reg-btn"), id="plus_reg_btn", on_click=answer_first_question
    ),
    state=ClientSG.start_question,
)

start_dialog = Dialog(start_window, start_question_window)
